<template>
  <Footer :class="prefixCls" v-if="false" ref="footerRef">
    <div class="footer-txt">
      <div style="color: gray">Copyright © 2024 AInnovation HGYC</div>
      <div
        >V3.0.10&nbsp;
        <template v-if="systemEnv">
          <span>
            |&nbsp;<span class="systemEnv-style">{{ systemEnv }}</span>
          </span>
        </template>
      </div>
    </div>
  </Footer>
</template>

<script lang="ts">
  import { computed, defineComponent, unref, ref } from 'vue';
  import { Layout } from 'ant-design-vue';
  import { DOC_URL, GITHUB_URL, SITE_URL } from '/@/settings/siteSetting';
  import { openWindow } from '/@/utils';
  import { useUserStore } from '/@/store/modules/user';

  import { useI18n } from '/@/hooks/web/useI18n';
  import { useRootSetting } from '/@/hooks/setting/useRootSetting';
  import { useDesign } from '/@/hooks/web/useDesign';
  import { useLayoutHeight } from '../content/useContentViewHeight';

  export default defineComponent({
    name: 'LayoutFooter',
    components: { Footer: Layout.Footer },
    setup() {
      const { t } = useI18n();
      const { getShowFooter } = useRootSetting();
      const { prefixCls } = useDesign('layout-footer');
      const userStore = useUserStore();
      let systemEnv = userStore.getSystemEnv;
      const footerRef = ref<ComponentRef>(null);
      const { setFooterHeight } = useLayoutHeight();

      const getShowLayoutFooter = computed(() => {
        if (unref(getShowFooter)) {
          const footerEl = unref(footerRef)?.$el;
          setFooterHeight(footerEl?.offsetHeight || 0);
        } else {
          setFooterHeight(0);
        }
        return true;
      });

      return {
        getShowLayoutFooter,
        prefixCls,
        t,
        DOC_URL,
        systemEnv,
        GITHUB_URL,
        SITE_URL,
        openWindow,
        footerRef,
      };
    },
  });
</script>
<style lang="less" scoped>
  .ant-layout-footer {
    padding: 10px 20px;
  }
  @prefix-cls: ~'@{namespace}-layout-footer';

  @normal-color: rgba(0, 0, 0, 0.45);

  @hover-color: rgba(0, 0, 0, 0.85);

  .@{prefix-cls} {
    color: @normal-color;
    text-align: center;

    &__links {
      margin-bottom: 8px;

      a {
        color: @normal-color;

        &:hover {
          color: @hover-color;
        }
      }
    }

    &__github {
      margin: 0 30px;

      &:hover {
        color: @hover-color;
      }
    }
  }

  .footer-txt {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #000;

    .systemEnv-style {
      color: #eb361d;
    }
  }
</style>
